﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8" />
    <title>版本管理</title>
    <link href="../lib/layui/css/layui.min.css" rel="stylesheet" />
    <link href="../x-admin/css/font.css" rel="stylesheet" />
    <link href="../x-admin/css/xadmin.css" rel="stylesheet" />
    <script type="text/javascript" src="../lib/Base64/base64.min.js"></script>
    <script type="text/javascript" src="../linq.js/linq.js"></script>
    <script src="../lib/layui/layui.js"></script>
    <script src="../lib/cookie/cookie.js"></script>
</head>
<body>
    <div class="layui-card">
        <table class="layui-table" id="versionTable" lay-filter="versionTable"></table>
    </div>
    <script type="text/html" id="versionbar">
        {{# if(d.catalogue!="dev"){ }}
        <a title="编辑" href="javascript:;" lay-event="edit"><i class="layui-icon">&#xe642;</i>编辑</a>
        <a title="删除" href="javascript:;" lay-event="delete"><i class="layui-icon">&#xe640;</i>删除</a>
        {{# } }}
    </script>
    <script type="text/html" id="versiontoolbar">
        <div class="layui-btn-container">
            <a class="layui-btn" lay-event="create">添加</a>
        </div>
    </script>

    <script>
        layui.use('table', function () {
            var table = layui.table;
            //第一个实例
            $tab = table.render({
                id: 'versionTable',
                elem: '#versionTable',
                skin: 'row',
                url: localStorage.getItem('hosttingaddr') + '/api/Version/index', //数据接口
                headers: { user: getCookie("userinfo") },
                page: true,
                toolbar:'#versiontoolbar',
                cols: [[ //表头
                    { field: 'id', title: 'ID', fixed: 'left', align: 'center' },
                    { field: 'name', title: '名称', align: 'center' },
                    { field: 'catalogue', title: '目录名称', align: 'center' },
                    { field: 'remark', title: '版本描述', align: 'center' },
                    { field: 'createTime', title: '创建时间', align: 'center' },
                    { fixed: 'right', title: '操作', align: 'center', toolbar: '#versionbar' }
                ]]
            });
            //监听表工具事件
            table.on('toolbar(versionTable)', function (obj) {
                var event = obj.event;
                switch (event) {
                    case "create":
                        layer.open({
                            type: 2,
                            title: '添加版本',
                            maxmin: true,
                            shadeClose: false, //点击遮罩关闭层
                            area: ['600px', '420px'],
                            content: 'versioncreate.html'// iframe链接地址
                        });
                        break;
                    case "packag":
                        layer.open({
                            type: 2,
                            title: '打包发布',
                            maxmin: true,
                            shadeClose: false, //点击遮罩关闭层
                            area: ['600px', '420px'],
                            content: 'processpackag.html'// iframe链接地址
                        });
                        break;
                    default: break;
                }
            });

            //监听行工具事件
            table.on('tool(versionTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值

                if (layEvent == 'edit') {
                    layer.open({
                        type: 2,
                        title: '编辑版本',
                        maxmin: true,
                        shadeClose: false, //点击遮罩关闭层
                        area: ['600px', '420px'],
                        content: 'versionedit.html' + '?id='+data.id // iframe链接地址
                    });
                }
                else if (layEvent == "delete") {
                    layer.confirm('确认要删除吗？', function (index) {
                        //发异步删除数据
                        layui.$.ajax({
                            type: "post",
                            url: localStorage.getItem('hosttingaddr') + '/api/version/deleteversion?id=' + data.id,
                            success: function (data) {
                                layer.msg('已删除!', { icon: 1, time: 1000 });
                                table.reload("versionTable");
                                layer.close(index);
                            }
                        });

                    });
                }
            });
        })
    </script>
</body>
</html>